<?php

namespace App\Http\Controllers\Admin\GameTool;

use App\Http\Requests\Admin\GameTool\ChatLogIndexRequest;
use App\Services\GameTool\ChatLogService;
use App\Http\Controllers\Admin\BaseController;

class ChatLogController extends BaseController
{

    public function __construct(ChatLogService $chatLogService)
    {
        $this->chatLogService = $chatLogService;
    }

    //聊天管理 列表页
    public function index(ChatLogIndexRequest $request)
    {
        $reqChannelId = $request->channel_id;
        $reqUniqueId = $request->unique_id;
        $reqChatChannelId = $request->chat_channel_id;

        $reqStartTime = $request->start_time;
        $reqEndTime = $request->end_time;

        $reqPageSize = $request->page_size;

        //获取聊天频道
        $data = $this->chatLogService->getAllChatLog($request);

        //滚屏,返回json
        if (\Request::isMethod('post') && $request['scroll'] === '1') {
            return $data;
        }

        return $this->view(null, compact(['reqStartTime', 'reqEndTime', 'reqChannelId', 'reqUniqueId', 'reqChatChannelId', 'reqPageSize', 'data']));
    }
}
